# Python GPIO development ***Copyright © Quectel Wireless Solutions Co., Ltd. 2026. All rights reserved.*** --- Basic procedure for accessing GPIO on Quectel Pi using Python. # Environment Verification ```bash gpiodetect ls -l /dev/gpiochip* gpioinfo python3 --version ``` | **Device Node** | **Description** | | --- | --- | | /dev/gpiochip0 | Currently verified as the primary GPIO controller, labeled 400000.pinctrl | | /dev/gpiochip1 | Currently verified as the PMIC-related GPIO controller | | /dev/gpiochip2 | Currently verified as the LPI-related GPIO controller | # Installing Dependencies It is recommended to use a virtual environment before installing the Python GPIO library. ```bash sudo apt update sudo apt install -y gpiod python3-venv python3-pip python3 -m venv .venv source .venv/bin/activate pip install python-periphery ``` # Input Reading Example This example uses line 36 on `/dev/gpiochip0`. Before development, refer to the M1 pin definition to verify the mapping between the physical pin and the line offset. ```python from periphery import GPIO chip = "/dev/gpiochip0" line = 36 gpio = GPIO(chip, line, "in") try: print(gpio.read()) finally: gpio.close() ``` # Output Example ```python from periphery import GPIO import time chip = "/dev/gpiochip0" line = 36 gpio = GPIO(chip, line, "out") try: gpio.write(True) time.sleep(1) gpio.write(False) finally: gpio.close() ``` # Important Notes - The GPIO line offset is not the physical header pin number. Verify the M1 pin definition before wiring. - Use `gpioinfo` to check whether a line is already in use by the system. Do not directly claim lines marked `[used]`. - The gpiod tool currently installed on the board is libgpiod v1.6.3. For command-line verification, refer to the GPIOD Usage Guide.